﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace PreProcessing
{
    class Pattern
    {
        public static string code = @"\b(and|array|as|b(ool(ean)?|reak)|c(ase|atch|har|lass|on(st|tinue))|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi|&nbsp|&#8211;|\b(\w+)?(&.*;)((\w+)?)\b";
        public static string tag = @"({.*?}|\[.*?\]|<.*?>)|{.*?}|\[.*?\]|<.*?>|/\*.*\*/";
        public static string line = @"\n{2,}|&.*;";
        public static string space = @"\s{2,}|\t{1,}";
        public static string others = @"\b(table\.MsoNormalTable)\b";
        public static string sign = "[.,;“”:()!?'`\\\"/'’‘<>-]|–|…|_";
        public static string codeDT = @"\[title\]|\[\/title\]|\[content\]|\[\/content\]|&quot|&gt|url:.*|title:|tom tat:|noi dung:|%|&nbsp";
        public static string vntext = "\b(^(r|d|đ|gi|v|ch|tr|s|x|l|n|q|b|c|k|g|gh|h|kh|m|ng|ngh|nh|p|ph|t|th))?(u|e|o|a|i|y|ie|uo|ai|au|ua|ia|ui|eu|oi|ay|uy|ou|ua|oa|ao|eo|ue|uya|uoi|uye|ieu|oai|oay|uoi|uou)((c|ch|m|n|ng|nh|u|p|t)$)?\b";
        public static string ConvertToUnSign(string text)
        {
            Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+");
            string strFormD = text.Normalize(System.Text.NormalizationForm.FormD);
            return regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D');
        }
    }
}
